const cloudHelper = require('../../../../helper/cloud_helper.js');
let behavior = require('../../../../behavior/default_index_bh.js');
let PassortBiz = require('../../../../biz/passport_biz.js');
let skin = require('../../skin/skin.js');

Page({
	behaviors: [behavior],

	onReady: function () {
		PassortBiz.initPage({
			skin,
			that: this,
			isLoadSkin: true,
			tabIndex: -1,
			isModifyNavColor: true
		});
    },
    bindOpenDoor: async function () {
        // console.log("bindOpenDoor");
        // wx.showLoading({
        //     title: '正在开门...',
        //     mask: true
        // });
        // setTimeout(function () {
        //     wx.hideLoading()
        //   }, 2000)
        // let opts = {
        //     title: 'bar'
        // }
        // let res = await cloudHelper.callCloudSumbit('passport/open_door', {}, opts);
        // console.log("bindOpenDoor,res:"+res);

        let opts = {
            title: '正在开门...'
        }
        await cloudHelper.callCloudSumbit('passport/open_door', {}, opts).then(res => {
            console.log("bindOpenDoor,res:"+JSON.stringify(res));
            console.log("result:"+res.data.result);
           let title = res.data.result ? '开门成功':'无权限';
            wx.showLoading({
                title: title,
                mask: true
            });
            setTimeout(function () {
                wx.hideLoading()
              }, 800)
        });
    }
})